<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
                "http://www.w3.org/TR/REC-html40/loose.dtd">
<html>
<head>
  <title>Description of assembleHistoneDSforClustering</title>
  <meta name="keywords" content="assembleHistoneDSforClustering">
  <meta name="description" content="Organizes histone modification data (GM06990, chrm 7) by chromosome regions">
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
  <meta name="generator" content="m2html &copy; 2003 Guillaume Flandin">
  <meta name="robots" content="index, follow">
  <link type="text/css" rel="stylesheet" href="../../m2html.css">
</head>
<body>
<a name="_top"></a>
<div><a href="../../index.html">Home</a> &gt;  <a href="../index.html">code</a> &gt; <a href="index.html">examples</a> &gt; assembleHistoneDSforClustering.m</div>

<!--<table width="100%"><tr><td align="left"><a href="../../index.html"><img alt="<" border="0" src="../../left.png">&nbsp;Master index</a></td>
<td align="right"><a href="index.html">Index for code\examples&nbsp;<img alt=">" border="0" src="../../right.png"></a></td></tr></table>-->

<h1>assembleHistoneDSforClustering
</h1>

<h2><a name="_name"></a>PURPOSE <a href="#_top"><img alt="^" border="0" src="../../up.png"></a></h2>
<div class="box"><strong>Organizes histone modification data (GM06990, chrm 7) by chromosome regions</strong></div>

<h2><a name="_synopsis"></a>SYNOPSIS <a href="#_top"><img alt="^" border="0" src="../../up.png"></a></h2>
<div class="box"><strong>function [regions]=assembleHistoneDSforClustering() </strong></div>

<h2><a name="_description"></a>DESCRIPTION <a href="#_top"><img alt="^" border="0" src="../../up.png"></a></h2>
<div class="fragment"><pre class="comment"> Organizes histone modification data (GM06990, chrm 7) by chromosome regions

 assembleHistoneDSforClustering() constructs a Region view of the data, by
 reorganizing histone modification data saved on 'GM06990chips_chrm7.mat'.
 The new DS 'regions' contains histone measurements organized by regions
 of the chromosome 7, and is used by performHistoneClustering() as data 
 source to plot the cluster tree and heatmap.
 
 'regions' also integrates data from different DAS sources. Annotation of
 genes is fetched from the Havana Gene Database at Sanger Institute, while
 the cancer link is obtained from the Genetic Association Database (GAD)
 at NCBI. 

 NOTE: Assembling regions can take several hours, since thousands of URL calls
 are made to retrieve information at Havana and GAD databases.

 SYNTAX: [] = assembleHistoneDS()

 See also assembleHistoneDS(), performHistoneClustering_Fig4CD()

    DASMiner: DAS library and browser for Matlab.
    Diogo Veiga, Jan 2009.</pre></div>

<!-- crossreference -->
<h2><a name="_cross"></a>CROSS-REFERENCE INFORMATION <a href="#_top"><img alt="^" border="0" src="../../up.png"></a></h2>
This function calls:
<ul style="list-style-image:url(../../matlabicon.gif)">
</ul>
This function is called by:
<ul style="list-style-image:url(../../matlabicon.gif)">
</ul>
<!-- crossreference -->

<h2><a name="_subfunctions"></a>SUBFUNCTIONS <a href="#_top"><img alt="^" border="0" src="../../up.png"></a></h2>
<ul style="list-style-image:url(../../matlabicon.gif)">
<li><a href="#_sub1" class="code">function [geneSymbol] = annotateGeneName(chrm,start,stop)</a></li><li><a href="#_sub2" class="code">function [cancerTypes] = annotateCancerLink(geneSymbol)</a></li></ul>
<h2><a name="_source"></a>SOURCE CODE <a href="#_top"><img alt="^" border="0" src="../../up.png"></a></h2>
<div class="fragment"><pre>0001 <a name="_sub0" href="#_subfunctions" class="code">function [regions]=assembleHistoneDSforClustering()</a>
0002 <span class="comment">% Organizes histone modification data (GM06990, chrm 7) by chromosome regions</span>
0003 <span class="comment">%</span>
0004 <span class="comment">% assembleHistoneDSforClustering() constructs a Region view of the data, by</span>
0005 <span class="comment">% reorganizing histone modification data saved on 'GM06990chips_chrm7.mat'.</span>
0006 <span class="comment">% The new DS 'regions' contains histone measurements organized by regions</span>
0007 <span class="comment">% of the chromosome 7, and is used by performHistoneClustering() as data</span>
0008 <span class="comment">% source to plot the cluster tree and heatmap.</span>
0009 <span class="comment">%</span>
0010 <span class="comment">% 'regions' also integrates data from different DAS sources. Annotation of</span>
0011 <span class="comment">% genes is fetched from the Havana Gene Database at Sanger Institute, while</span>
0012 <span class="comment">% the cancer link is obtained from the Genetic Association Database (GAD)</span>
0013 <span class="comment">% at NCBI.</span>
0014 <span class="comment">%</span>
0015 <span class="comment">% NOTE: Assembling regions can take several hours, since thousands of URL calls</span>
0016 <span class="comment">% are made to retrieve information at Havana and GAD databases.</span>
0017 <span class="comment">%</span>
0018 <span class="comment">% SYNTAX: [] = assembleHistoneDS()</span>
0019 <span class="comment">%</span>
0020 <span class="comment">% See also assembleHistoneDS(), performHistoneClustering_Fig4CD()</span>
0021 <span class="comment">%</span>
0022 <span class="comment">%    DASMiner: DAS library and browser for Matlab.</span>
0023 <span class="comment">%    Diogo Veiga, Jan 2009.</span>
0024 
0025 load(<span class="string">'GM06990chips_chrm7.mat'</span>, <span class="string">'histoneChips'</span>);
0026 
0027 regions = struct(<span class="string">'label'</span>,{},<span class="string">'samples'</span>,{},<span class="string">'values'</span>,{} );
0028 regCount = 0;
0029 
0030 
0031 <span class="keyword">for</span> i=1:size(histoneChips.chips,2)
0032    
0033     <span class="keyword">for</span> j=1:size(histoneChips.chips(i).region,2)
0034        
0035         regLabel = [<span class="string">'chr'</span> histoneChips.chips(i).region(j).chrm <span class="string">':'</span> histoneChips.chips(i).region(j).start <span class="keyword">...</span>
0036             <span class="string">','</span> histoneChips.chips(i).region(j).stop];
0037         
0038         res = strcmpi(regLabel,{regions.label});
0039         <span class="keyword">if</span> (any(res))
0040             index = find(res,1); <span class="comment">%get index for label matching</span>
0041             
0042             regions(index).samples = [regions(index).samples ; histoneChips.chips(i).sample];
0043             regions(index).values = [regions(index).values ; histoneChips.chips(i).values(j)];
0044         
0045         <span class="keyword">else</span> <span class="comment">%add a new region</span>
0046            regCount = regCount+1; 
0047            regions(regCount).label = regLabel;
0048            regions(regCount).samples = {histoneChips.chips(i).sample};
0049            regions(regCount).values = histoneChips.chips(i).values(j);
0050            regions(regCount).geneSymbol = <a href="#_sub1" class="code" title="subfunction [geneSymbol] = annotateGeneName(chrm,start,stop)">annotateGeneName</a>(histoneChips.chips(i).region(j).chrm, <span class="keyword">...</span>
0051                histoneChips.chips(i).region(j).start, histoneChips.chips(i).region(j).stop);
0052         <span class="keyword">end</span>
0053         
0054     <span class="keyword">end</span>
0055 <span class="keyword">end</span>
0056 
0057 <span class="keyword">for</span> i=1:size(regions,2)
0058     regions(i).cancerTypes = <a href="#_sub2" class="code" title="subfunction [cancerTypes] = annotateCancerLink(geneSymbol)">annotateCancerLink</a>(regions(i).geneSymbol);
0059 <span class="keyword">end</span>
0060 
0061 save GM06990chips_chrm7_RegionsView.mat regions;
0062 
0063 <a name="_sub1" href="#_subfunctions" class="code">function [geneSymbol] = annotateGeneName(chrm,start,stop)</a>
0064 <span class="comment">%Accessing Havana Genes Database</span>
0065 <span class="comment">%eg. http://das.sanger.ac.uk/das/otter_das/features?segment=7:116391273,116392269</span>
0066 
0067 [xmlS] = executeDASCommand(<span class="string">'http://das.sanger.ac.uk/das'</span>,<span class="string">'command'</span>, <span class="string">'features'</span>, <span class="string">'DSN'</span>, <span class="string">'otter_das'</span>,<span class="string">'chrom'</span>,chrm,<span class="string">'start'</span>,start <span class="keyword">...</span>
0068     , <span class="string">'stop'</span>, stop, <span class="string">'timeout'</span>, 5000);
0069 
0070 geneSymbol = <span class="string">''</span>;
0071 <span class="keyword">if</span> (isstruct(xmlS)) <span class="comment">% ow problem in the server</span>
0072     <span class="keyword">if</span> ( isfield(xmlS.GFF{1}.SEGMENT{1},<span class="string">'FEATURE'</span>)    )
0073 
0074         <span class="keyword">for</span> i=1:size(xmlS.GFF{1}.SEGMENT{1}.FEATURE,2)
0075             <span class="keyword">if</span> (~strcmp (xmlS.GFF{1}.SEGMENT{1}.FEATURE{i}.NOTE{7}.CONTENT(10:end),geneSymbol))
0076                 <span class="keyword">if</span> (strcmp(geneSymbol,<span class="string">''</span>))
0077                     geneSymbol = [xmlS.GFF{1}.SEGMENT{1}.FEATURE{i}.NOTE{7}.CONTENT(10:end) <span class="string">','</span>];
0078                 <span class="keyword">elseif</span> (strfind(geneSymbol,[xmlS.GFF{1}.SEGMENT{1}.FEATURE{i}.NOTE{7}.CONTENT(10:end) <span class="string">','</span>])) <span class="comment">%already on the list</span>
0079                     <span class="keyword">continue</span>;
0080                 <span class="keyword">else</span>
0081                     geneSymbol = [geneSymbol xmlS.GFF{1}.SEGMENT{1}.FEATURE{i}.NOTE{7}.CONTENT(10:end) <span class="string">','</span>]; <span class="comment">%new gene</span>
0082                 <span class="keyword">end</span>
0083             <span class="keyword">end</span>
0084         <span class="keyword">end</span>
0085 
0086     <span class="keyword">end</span>
0087 <span class="keyword">end</span>
0088 
0089 <a name="_sub2" href="#_subfunctions" class="code">function [cancerTypes] = annotateCancerLink(geneSymbol)</a>
0090 
0091 cancerTypes = <span class="string">''</span>;
0092 geneTokens = regexp(geneSymbol,<span class="string">','</span>,<span class="string">'split'</span>);
0093 
0094 <span class="keyword">for</span> k=1:(size(geneTokens,2)-1)
0095     <span class="comment">% Accessing the Genetic Association Database</span>
0096     <span class="comment">% eg. http://www.ebi.ac.uk/das-srv/genedas/das/gad/features?segment=GSTT1</span>
0097     [xmlS] = executeDASCommand(<span class="string">'http://www.ebi.ac.uk/das-srv/genedas/das'</span>,<span class="string">'command'</span>, <span class="string">'features'</span>, <span class="string">'DSN'</span>, <span class="string">'gad'</span>,<span class="string">'segment'</span>,geneTokens{k});
0098 
0099  <span class="keyword">if</span> (isstruct(xmlS)) <span class="comment">% ow problem in the server</span>
0100     <span class="keyword">if</span> ( isfield(xmlS.GFF{1}.SEGMENT{1},<span class="string">'FEATURE'</span>) )
0101 
0102         <span class="keyword">for</span> i=1:size(xmlS.GFF{1}.SEGMENT{1}.FEATURE,2)
0103 
0104             <span class="keyword">for</span> j=1:size(xmlS.GFF{1}.SEGMENT{1}.FEATURE{i}.NOTE,2)
0105 
0106                 <span class="keyword">if</span> (strfind(xmlS.GFF{1}.SEGMENT{1}.FEATURE{i}.NOTE{j}.CONTENT,<span class="string">'CANCER/'</span>))
0107 <span class="comment">%                     cancerTypes = [cancerTypes ',' xmlS.GFF{1}.SEGMENT{1}.FEATURE{i}.NOTE{j}.CONTENT(8:end)];</span>
0108                     <span class="keyword">if</span> (strcmp(cancerTypes,<span class="string">''</span>))
0109                         cancerTypes = [xmlS.GFF{1}.SEGMENT{1}.FEATURE{i}.NOTE{j}.CONTENT(8:end) <span class="string">','</span>];
0110                     <span class="keyword">elseif</span> (strfind(cancerTypes,[xmlS.GFF{1}.SEGMENT{1}.FEATURE{i}.NOTE{j}.CONTENT(8:end) <span class="string">','</span>])) <span class="comment">%already on the list</span>
0111                         <span class="keyword">continue</span>;
0112                     <span class="keyword">else</span>
0113                         cancerTypes = [cancerTypes xmlS.GFF{1}.SEGMENT{1}.FEATURE{i}.NOTE{j}.CONTENT(8:end) <span class="string">','</span>]; <span class="comment">%new gene</span>
0114                     <span class="keyword">end</span>
0115                 <span class="keyword">end</span>
0116             <span class="keyword">end</span>
0117             
0118         <span class="keyword">end</span>
0119     <span class="keyword">end</span>
0120  <span class="keyword">end</span>
0121 
0122 <span class="keyword">end</span></pre></div>
<hr><address>Generated on Tue 17-Feb-2009 16:59:45 by <strong><a href="http://www.artefact.tk/software/matlab/m2html/">m2html</a></strong> &copy; 2003</address>
</body>
</html>